/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 * for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

#include "threadbuilderfactory.h"
#include "templatethreadbuilder.h"
#include "paths.h"

namespace Wishmaster
{
	ThreadBuilderFactory::ThreadBuilderFactory()
	{
		addBuilder(new TemplateThreadBuilder());
	}

	ThreadBuilderFactory::~ThreadBuilderFactory()
	{
		for(QMap<QString, ThreadBuilder*>::iterator it = m_builders.begin();
				it != m_builders.end(); ++it)
		{
			delete it.value();
		}
		m_builders.clear();
	}

	QStringList ThreadBuilderFactory::availableBuilders()
	{
		return m_builders.keys();
	}

	ThreadBuilderPtr ThreadBuilderFactory::builder(const QString& id)
	{
		QMap<QString, ThreadBuilder*>::iterator it = m_builders.find(id);
		if(it == m_builders.end())
			return ThreadBuilderPtr();
		return it.value()->clone();
	}

	void ThreadBuilderFactory::addBuilder(ThreadBuilder* builder)
	{
		m_builders.insert(builder->id(), builder);
	}
}

